<style>
body {
  min-width:300px;
  overflow-x:hidden;
}
#rename-this_newName {
  width:100%;
}
</style>

<input type="text" id="rename-this_newName" onkeyup="rename_this_doit(this.value)"/>

<script>

var bg = chrome.extension.getBackgroundPage();
var tabNames = bg.tabNames;

function rename_this_doit(newName)
{
	chrome.tabs.executeScript(null, {code: 'document.title = "'+newName+'";'}, function(){});
	chrome.tabs.getSelected(null, function(tab){ tabNames[tab.id] = tab.title });
}

function onPopup()
{
	var field = document.getElementById("rename-this_newName");
	chrome.tabs.getSelected(null, function(tab){
		field.value = tabNames[tab.id] ? tabNames[tab.id] : tab.title;
	});
	field.select();
	field.focus();
}

onPopup();

</script>

